var t = getApp(), e = t.requirejs("core"), a = t.requirejs("foxui"), i = t.requirejs("biz/diyform"), n = t.requirejs("jquery");

Page({
    data: {
        icons: t.requirejs("icons"),
        submit: !1,
        levelname:'',
        jhlevelname:'',
        code:''
    },
    onLoad: function(e) {
    },
    onShow: function() {
        this.getInfo();
    },
    getInfo:function(){
        var th = this;
        e.get("member/jhlevel/getbasic",{},function(res){
            th.setData({
                levelname: res.level.levelname,
            });
        })
    },
    onBlur: function(t) {
        var th = this;
        var code = t.detail.value;
        // 查询激活码激活等级以及验证激活码是否已经失效
        e.get("member/jhlevel/getmsg", {code:code}, function(res) {
            if(res.error==0){
                th.setData({
                    jhlevelname: res.level.levelname,
                    code:code
                });
            }else{
                th.setData({
                    jhlevelname: res.message,
                    code:code
                });
                a.toast(th, res.message);
            }
        })
    },
    submit: function() {
        if (!this.data.submit) {
            var t = this;
            if (!t.data.code) return void a.toast(t, "请填写激活码!");
            t.setData({
                submit: !0
            });
            e.post("member/jhlevel/submit", {code:t.data.code}, function(res) {
                if(res.error==0){
                    t.setData({
                        submit: !1
                    })
                    a.toast(t, "激活成功")
                    setTimeout(function() {
                        wx.navigateBack();
                    }, 500)
                }else{
                    a.toast(t, res.message)
                }
            });
        }
    },
    bindChange: function(t) {
        return i.bindChange(this, t);
    },
    onCancel: function(t) {
        return i.onCancel(this, t);
    },
});